﻿//-----------------------------------------------------------------------
// <copyright file="SlwyMvcContext.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: SlwyMvcContext.cs
// * history : created by qinchaoyue 2017-11-22 03:55:42
// </copyright>
//-----------------------------------------------------------------------

using Slwy.FrameCore.Dependency;
using Slwy.Logger.Contracts;
using Slwy.Utility.Extensions;

namespace Slwy.Mvc.Context
{
    using Microsoft.AspNetCore.Http;

    public static class SlwyMvcContext
    {
        public static HttpContext GetContext()
        {
            var logger = ServiceLocator.Instance.GetServiceEx<ILogger>();
            var factory = ServiceLocator.Instance.GetService(typeof(IHttpContextAccessor));
            if (factory == null)
            {
                logger.Error("factory is null");
            }

            //ServiceProvider.
            var context = ((IHttpContextAccessor)factory).HttpContext;
            return context;
        }
    }
}
